package demo.day11_CollectionAddpackage.List;


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/2-08-02-10:11
 * @Description：demo.day11_CollectionAddpackage.List
 */

/*
    vector 线程安全
 */
public class list_use {
    public static final int max=100000;
    public static void main(String[] args) {
        //List list = new ArrayList();
        List list = new LinkedList();
        //开始时间
        //时间戳1970-现在
        long starttime = System.currentTimeMillis();
        for (int i = 0; i < max; i++) {
            list.add(i,"hello"+i);
        }
        long endtime = System.currentTimeMillis();
        System.out.printf("共耗费：%d 毫秒\n",(endtime-starttime));

        starttime = System.currentTimeMillis();
        for (int i = 0; i < max; i++) {
            list.get(i);
        }
        endtime = System.currentTimeMillis();
        System.out.printf("共耗费：%d 毫秒\n",(endtime-starttime));
    }
//    public static void main(String[] args) {
//        //List继承Collection接口：   有序、有索引、可重复
//        List list = new ArrayList();
//        list.add(1);
//        list.add(7);
//        list.add("sff");
//        list.add(1,4);
//        System.out.println(list);
//    }
}
